﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using XukaShop.Models.Entities;

namespace XukaShop.Models.ConcertModel
{
    public class CustomRoleProvider : RoleProvider
    {
        private FashionShopEntities _db = new FashionShopEntities();

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

        public override string[] GetRolesForUser(string username)
        {
            var selectMember = (from member in _db.Member
                                where member.UserName == username
                                    && member.IsDelete == false
                                select member).FirstOrDefault();
            var selectRole = (from memberRole in _db.Role
                              where memberRole.Id == selectMember.Id
                              select memberRole).FirstOrDefault();
            switch (selectRole.Id)
            {
                case 1:
                    {
                        return new[] { "Administrator" };
                    }
                case 2:
                    {
                        return new[] { "Member" };
                    }
                case 3:
                    {
                        return new[] { "Staff" };
                    }
                default:
                    return new string[] { };
            }
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
    }
}